﻿using System;
using System.Collections.Generic;

namespace Allegro.TaskExecution
{
    /// <summary>
    /// Interface for identifiable objects
    /// </summary>
    public interface IIdentity
    {
        /// <summary>
        /// Task id
        /// </summary>
        Guid Oid { get; }

        /// <summary>
        /// Task name
        /// </summary>
        string Name { get; set; }
    }
    /// <summary>
    /// Composite item
    /// </summary>
    /// <typeparam name="I"></typeparam>
    public interface ICompositeItem<I> : IIdentity where I : IIdentity
    {
        /// <summary>
        /// Look up child item by name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        I this[string name] { get;}

        /// <summary>
        /// Look up child item by oid
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        I this[Guid oid] { get; }

        /// <summary>
        /// Return list of child items
        /// </summary>
        IList<I> Items { get; }

        /// <summary>
        /// Add child item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        ICompositeItem<I> Add(I item);

        /// <summary>
        /// Remove item
        /// </summary>
        /// <param name="item"></param>
        void Remove(I item);

        /// <summary>
        /// Remove item by name
        /// </summary>
        /// <param name="name"></param>
        void Remove(string name);
        
    }
}
